package com.maple.soa.controller;

import com.maple.soa.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lijian
 * @date 2020/8/7
 */
@RestController
@RequestMapping("/redis")
@Slf4j
public class RedisController {
    @Autowired
    private RedisService redisService;

    @RequestMapping("/set")
    public String set() {
        log.info("---> redis set!");
        redisService.set("lj_test", "Maple-test", 30 * 60);

        return "success";
    }

    @RequestMapping("/get/{key}")
    public String get(@PathVariable("key") String key) {
        return redisService.get(key);
    }
}
